import { BaseSkill } from '../BaseSkill';
import { DamageType, SkillType } from '../../types';
import { General } from '../../models/General';
import { Battle } from '../../models/Battle';

export class XueZhan extends BaseSkill {
  private readonly HP_THRESHOLD = 0.2;
  private readonly DAMAGE_BOOST = 0.5;

  constructor() {
    super(
      'xueZhan',
      '血战',
      SkillType.Passive,
      DamageType.Physical,
      1,          // 触发概率 100%
      0,          // 无需冷却
      999         // 持续到战斗结束（使用一个足够大的数字）
    );
  }

  execute(source: General, battle: Battle): void {
    if (source.troops / source.maxTroops <= this.HP_THRESHOLD) {
      source.addEffect({
        type: 'physicalDamageBoost',
        value: this.DAMAGE_BOOST,
        duration: 999,  // 持续到战斗结束
        stackable: false // 防止效果叠加
      });
    }
  }
}
